+=====-========-========-========-========-========-========-========-========+ | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |Byte | | | | | | | | | |=====+========+========+=====================================================| | 0 | | | | | | | | | |-----+-----------------------------------------------------------------------| | 1 | | | | | DTR | CTS | XON/OFF| XON/OFF| | | | | | | Output | Input | Input | Output | |-----+-----------------------------------------------------------------------| | 2 | XON character | |-----+-----------------------------------------------------------------------| | 3 | XOff character | +=============================================================================+
The high word (16 bits) of the integer is a bitmap with 1 or more of the following bits set:
kOTSerialXOnOffInputHandshake = 1 kOTSerialXOnOffOutputHandshake = 2 kOTSerialCTSInputHandshake = 4 kOTSerialDTROutputHandshake = 8
The 2nd lowest byte is the XOn character value; the lowest byte is the XOff character value.
If these values are 0, and XOnOff handshaking was requested, the default values of control-S for XOff and control-Q for XOn will be used.
There is an inline function (or #define for C users)
SerialHandshakeData(type, onChar, offChar)
defined in OpenTptSerial.h can be used to create this 4-byte value. The default value
of this option is no handshaking.
For instance, if you wish to enable XON/XOFF input handshaking, but you wanted to specify that the XON char be a ^T instead of an ^Q. You would create an option structure in this manner.
TOption opt; opt.len = kOTFourByteOptionSize; opt.level = XTI_GENERIC; opt.name = SERIAL_OPT_HANDSHAKE; opt.value = OTSerialHandshakeData ( kOTSerialXOnOffInputHandshake, ('T' & ~0x40), // normally kOTSerialDefaultOnChar kOTSerialDefaultOffChar);You also have the ability to control the XOff state of the serial input port by using the the I_SetSerialXOffState Ioctl Command. A value of 0 will unconditionally clear the XOFF state, while a value of 1 will unconditionally set it.
OTIoctl(theSerialEndpoint, I_SetSerialXOffState, 1); // Set XOFF state to ON
The I_SetSerialXOn Ioctl causes the serial port to send an XON character. A value of 0 will only cause it to be sent if we're in the XOFF state, while a value of 1 will unconditionally send the character.
OTIoctl(theSerialEndpoint, I_SetSerialXOn, 1); // Unconditionally send an XON
Conversely, the I_SetSerialXOff Ioctl causes the serial port to send an XOFF character. A value of 0 will only cause it to be sent if we're in the XONstate, while a value of 1 will unconditionally send the character.
OTIoctl(theSerialEndpoint, I_SetSerialXOff, 1); // Unconditionally send an XOFF